<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <script src="https://cdn.bootcdn.net/ajax/libs/angular.js/1.6.8/angular.min.js"></script>
  </head>
  <body>
    <div ng-app="myApp" ng-controller="myCtrl">
      <h1>{{indexName}}</h1>
      <!-- 自定义组件 -->
      <div>{{name}}</div>
      <section ng-controller="childCtrl">
        <div>{{name}}</div>
      </section>
    </div>

    <script>
      var app = angular.module("myApp", []);
      app.controller("myCtrl", function ($scope) {
        $scope.indexName = "主页";
        $scope.name="父controller的name";
      });
      app.controller("childCtrl",function($scope){
        // 当前controller没有name属性，会取父controller中的name属性
      })
    </script>
  </body>
</html>
